package users.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.annotation.JSONField;

import common.pojo.BasePojo;

/***
 * 菜单表
 * @author lby
 *添加了查询子菜单，查询自己的叶子菜单List<AMenu>
 *添加了擦查询角色菜单，查询到本菜单对应的角色有哪些  List<ARoleMenu>
 *天机了额外的字段，描述 treeName
 *
 */
public class AMenu extends BasePojo<AMenu>
{
	/***
	 * 主键，id
	 */                    
	private int id;
	/***
	 * 上一级id
	 */
	private int parentId;
	/***
	 * 名字
	 */
	private String name;
	/***
	 * 链接
	 */
	private String url;
	/***
	 * 描述
	 */
	private String content;
	/***
	 * 是否在主菜单显示:0:不显示,1:显示
	 */
	private byte showStatus;
	/***
	 * 叶子:0:非叶子,1:叶子
	 */
	private byte leafStatus;
	/***
	 * 状态
	 */
	private byte status ;
	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;
	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	private Date updateTime;
	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	private Date pubTime;
	/***
	 * 是否在主菜单显示:0:不显示,1:显示
	 * 字符串描述
	 */
	private String showStatusStr;
	/***
	 * 叶子描述
	 */
	private String leafStatusStr ;
	/***
	 * 状态描述
	 */
	private String statusStr ;
	/***
	 * 额外字符串，存储结果
	 */
	private String treeName;
	/***
	 * 关联关系，
	 * 多对一，一个菜单只能有一个父菜单
	 */
	private AMenu parentMenu ;
	/***
	 * 一对多，一个菜单有多个子菜单
	 */
	private List<AMenu>childMenuList = new ArrayList<AMenu>();
	
	/**
	 * 一个菜单有多个角色菜单
	 */
	private List<ARoleMenu> childRoleMenuList = new ArrayList<ARoleMenu>();
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	public int getParentId()
	{
		return parentId;
	}
	public void setParentId(int parentId)
	{
		this.parentId = parentId;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public String getUrl()
	{
		return url;
	}
	public void setUrl(String url)
	{
		this.url = url;
	}
	public String getContent()
	{
		return content;
	}
	public void setContent(String content)
	{
		this.content = content;
	}
	public byte getShowStatus()
	{
		return showStatus;
	}
	public void setShowStatus(byte showStatus)
	{
		this.showStatus = showStatus;
	}
	public byte getLeafStatus()
	{
		return leafStatus;
	}
	public void setLeafStatus(byte leafStatus)
	{
		this.leafStatus = leafStatus;
	}
	public byte getStatus()
	{
		return status;
	}
	public void setStatus(byte status)
	{
		this.status = status;
	}
	public Date getCreateTime()
	{
		return createTime;
	}
	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}
	public Date getUpdateTime()
	{
		return updateTime;
	}
	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}
	public Date getPubTime()
	{
		return pubTime;
	}
	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}
	public AMenu getParentMenu()
	{
		return parentMenu;
	}

	public void setParentMenu(AMenu parentMenu)
	{
		this.parentMenu = parentMenu;
	}
	public List<AMenu> getChildMenuList()
	{
		return childMenuList;
	}
	public void setChildMenuList(List<AMenu> childMenuList)
	{
		this.childMenuList = childMenuList;
	}
	public String getShowStatusStr()
	{
		AMenuEnum []values = AMenuEnum.values();
		for(int i = 0 ; i <= values.length ;i++)
		{
			AMenuEnum menuEnumTemp = values[i] ;
			/***
			 * toString :变量名
			 * name：枚举的键
			 * getStatus:枚举的值
			 */
			if(menuEnumTemp.toString().startsWith("SHOW_STATUS"))
			{
				if(menuEnumTemp.getStatus()== this.showStatus)
				{
					this.showStatusStr = menuEnumTemp.getName();
				}
			}
		}
		return showStatusStr ;
	}
	public String getLeafStatusStr()
	{
		AMenuEnum[] values = AMenuEnum.values();
		for(int i= 0 ; i <=values.length ;i++)
		{
			AMenuEnum menuEnumTemp = values[i];
			/*
			 * tostring:变量名
			 * name:枚举
			 * getStatus:枚举的值
			 */
			if(menuEnumTemp.toString().startsWith("LEAF_STATUS"))
			{
				if(menuEnumTemp.getStatus() == this.leafStatus)
				{
					this.leafStatusStr = menuEnumTemp.getName() ;
				}
			}
		}
		return leafStatusStr ;
	} 
	public String getStatusStr()
	{
		AMenuEnum [] values = AMenuEnum.values() ;
		for(int i = 0 ; i < values.length ; i ++)
		{
			AMenuEnum menuEnumTemp = values[i] ;
			/*
			 * toString:变量名
			 * name:枚举的键
			 * getStatus:枚举的值 
			 */
			if(menuEnumTemp.toString().startsWith("STATUS"))
			{
				if(menuEnumTemp.getStatus() == this.status)
				{
					this.statusStr = menuEnumTemp.getName() ;
				}
			}
		}
		return statusStr;
	}

	public String getTreeName()
	{
		return treeName;
	}

	public void setTreeName(String treeName)
	{
		this.treeName = treeName;
	}

	public List<ARoleMenu> getChildRoleMenuList()
	{
		return childRoleMenuList;
	}

	public void setChildRoleMenuList(List<ARoleMenu> childRoleMenuList)
	{
		this.childRoleMenuList = childRoleMenuList;
	}
}
